<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* 
*/
class UserSurvey extends MY_Controller
{
	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('Statis/SurveyModel','survey');
	}

	//
	public function index()
	{	
		$data = $this->survey->analyse_member();
		$this->load->view('user_survey', $data);
	}


	//
	public function get_list()
	{
		$type = $this->input->get('type', TRUE);   //类型
		$dnum = $this->input->get('dnum', TRUE);   //天数

		$res = $this->survey->member_data($type,$dnum);

		if ($res) 
		{
			$data = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();
	}


	//会员付费
	public function user_consu()
	{
		$res = $this->survey->user_consu_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}


	//会员性别
	public function user_sex()
	{
		$res = $this->survey->user_sex_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}


	//年龄分布
	public function user_age()
	{
		$sex = $this->input->get('sex',TRUE);
		$res = $this->survey->user_age_data($sex);

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}


	//预约信息
	public function user_appoin()
	{
		$res = $this->survey->user_appoin_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}


}



?>